package com.example.android.commitcontent.ime.cores.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.List;

public class GeneralFragmentPagerAdapter extends FragmentPagerAdapter {
    private List<? extends CharSequence> mTitleList;
    private List<? extends Fragment> mFragments;

    public GeneralFragmentPagerAdapter(FragmentManager fm, List<? extends Fragment> fragments) {
        super(fm);
        mFragments = fragments;
    }


    public GeneralFragmentPagerAdapter(FragmentManager fm, List<? extends Fragment> fragments, List<? extends CharSequence> titles) {
        super(fm);
        mFragments = fragments;
        mTitleList = titles;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return mTitleList == null ? "" : mTitleList.get(position);
    }
}
